/*
 * Project it.battlehorse.rcp.tools
 * Created on May 13, 2006
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * A copy of the LGPL is available also at
 * http://www.gnu.org/copyleft/lesser.html
 * 
 */ 
package it.battlehorse.rcp.tools.actors;

import org.eclipse.jface.action.IAction;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionListener;

/**
 * This interface defines the methods needed to execute Actors.
 * An instance of this class can be retrieved via the Service locator framework
 * 
 * @author battlehorse
 * @since May 13, 2006
 */
public interface IActorRunner {

	/**
	 * Executes the task associated with the given actorId
	 * 
	 * @param actorId the id of the actor whose associated task must be executed.
	 */
	public void runJob(String actorId);

	/**
	 * Adds a listener which is notified on runner events
	 * 
	 * @param listener  a listener which is notified on runner events
	 */
	public void addRunnerListener(IActorRunnerListener listener);

	/**
	 * Removes a listener from notification on runner events
	 * 
	 * @param listener the listener to be removed
	 */
	public void removeRunnerListener(IActorRunnerListener listener);
	
	/**
	 * A utility method which returns a {@code SelectionListener} ready to be attached
	 * to a button, which will then trigger the execution of the actor associated with
	 * the given id.
	 * 
	 * @param actorId the id of the actor which will be executed when the returned listener
	 * 	is triggered
	 * @return a listener which executes the given actor when triggered.
	 */	
	public SelectionListener newButtonActorLauncher(String actorId);

	/**
	 * A utility method which returns a {@code KeyListener} ready to be attached
	 * to a widget, which will then trigger the execution of the actor associated with
	 * the given id.
	 * 
	 * @param actorId the id of the actor which will be executed when the returned listener
	 * 	is triggered
	 * @param c the character that must be pressed to activate the listener
	 * @param stateMask the state mask that must match to activate the listener
	 * @return a listener which executes the given actor when triggered.
	 * 
	 */	
	public KeyListener newKeyActorLauncher(String actorId, char c, int stateMask);
	
	/**
	 * A utility method which returns an {@code IAction} ready to be added
	 * to a menu or a toolbar, which will then trigger the execution of the actor
	 * associated with the given id.
	 * 
	 * @param actorId the id of the actor which will be executed when the returned action
	 * 	is triggered
	 * @return an action which executes the given actor when triggered.
	 */	
	public IAction getActionActorLauncher(String actorId);
}